<template>
  <el-form>
    <el-form-item label="用户昵称">
      <el-input v-model.trim="dateForm.nickname"/>
    </el-form-item>
    <el-form-item label="用户密码">
      <el-input type="password" v-model.trim="dateForm.password"/>
    </el-form-item>
    <el-form-item>
      <el-button type="primary" @click="submit">提交</el-button>
    </el-form-item>
  </el-form>
</template>

<script>

import { updateUserInfo } from '@/api/admin/user'

export default {
  props: {
    user: {
      type: Object,
      default: () => {
        return {
            id: '',
            nickname: '',
            password: ''
        }
      }
    }
  },
  mounted() {
    this.dateForm = this.user
  },
  data() {
    return {
      dateForm: {
        id: undefined,
        nickname: undefined,
        password: undefined
      }
    }
  },
  methods: {
    submit() {
      updateUserInfo(this.dateForm).then(res => {
        // this.resetForm()
        this.$notify({
          title: '修改成功',
          type: 'success',
          duration: 2500
        })
      }).catch(err => {
        console.log(err.message)
      })
    }
  }
}
</script>
